﻿using EMall.IdentityService.Menus;
using EMall.IdentityService.PermissionGrants;
using EMall.IdentityService.Roles;
using EMall.IdentityService.Users;
using EMall.Query;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using System.Security.Claims;

namespace EMall.IdentityService.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class PermissionGrantController : ControllerBase
    {
        private readonly IPermissionGrantAppService _permissionGrantAppService;
        public PermissionGrantController(IPermissionGrantAppService permissionGrantAppService)
        {
            _permissionGrantAppService = permissionGrantAppService;
        }
        [HttpPost]
        public async Task SetPermissionsAsync(SetPermissionsDto input)
        {
            await _permissionGrantAppService.SetPermissionsAsync(input);
        }
        [HttpGet]
        public async Task<IEnumerable<string>> GetPermissionsAsync([FromQuery] GetPermissionsQueryDto input)
        {
            return await _permissionGrantAppService.GetPermissionsAsync(input);
        }
    }
}
